/*
 *    Copyright (c) 2018-2025, madp All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: 成都文思海辉金信软件有限公司
 */

package com.pactera.madp.daemon.quartz.task;

import cn.hutool.json.JSONUtil;
import com.pactera.madp.common.core.constant.SecurityConstants;
import com.pactera.madp.cp.api.dto.sync.SyncDTO;
import com.pactera.madp.cp.api.feign.RemoteSyncService;
import com.pactera.madp.daemon.quartz.constant.enums.MadpQuartzEnum;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


/**
 * 同步Crm、Hr、Fina、Sale系统数据任务
 */
@Slf4j
@Component("syncTask")
@AllArgsConstructor
public class SyncTask {

	private final RemoteSyncService remoteSyncService;

	/**
	 * 同步数据
	 */
	@SneakyThrows
	public String syncData(String para) {
		log.info("输入参数{}", para);
		SyncDTO dto = JSONUtil.toBean(para, SyncDTO.class);
		remoteSyncService.sync(dto, SecurityConstants.FROM_IN);
		return MadpQuartzEnum.JOB_LOG_STATUS_SUCCESS.getType();
	}

}
